<template>
    <el-dropdown trigger="click" @command="handleCommand" v-if="list.length>0">
        <el-button size="mini">
            常用语<i class="el-icon-arrow-down el-icon--right"></i>
        </el-button>
        <el-dropdown-menu slot="dropdown">
            <template  v-for="(item,index) in list">
            <el-dropdown-item :command="item.suggestion" :key="index">{{item.text}}</el-dropdown-item>
            </template>
        </el-dropdown-menu>
    </el-dropdown>
</template>
<script>
    import schoolSignature from "@/api/officialDocument/schoolSignature/index";
    export default {
        name: "MoreMsg",
        components: {},
        data() {
            return {
                list:[]
            };
        },
        created() {
            this.getTicketsUserMsg()
        },
        methods: {
            handleCommand(command) {
                this.$emit("setSuggestion",command)
            },
            getTicketsUserMsg() {
                schoolSignature.getTicketsUserMsg().then(res => {
                    this.list = res.data
                    // this.list.unshift({suggestion:"拟同意"})
                    // this.list.unshift({suggestion:"同意"})
                    this.list.map(item => {
                        item.text = item.suggestion.length>20?item.suggestion.substring(0,20)+"...":item.suggestion
                    })
                })
            },
        }
    };
</script>
<style lang="scss" scoped>
</style>

